<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>瑜伽分馆</title>
$!{include("import_js_css.html")}
</head>
<body>
	$!{include("header.html")}
	<div class="container menu_all">
		<div class="div_search_result clear">
			<div class="panel-heading panel-result-title">
				<h3 class="panel-title">查询结果</h3>
				<div class="btn-group btn-group-sm btn-gp-default">
					<button id="btn_edit" type="button"
						class="btn btn-default panel-radius-left" onclick="window.location.href='yueyogaAdmin/toAddHall.jhtml'">创建</button>
					<button id="btn_edit" type="button"
						class="btn btn-default panel-radius-none" onclick="updateHall()">修改</button>
					<button id="btn_delete" type="button"
						class="btn btn-default panel-radius-right" onclick="deleteHall()">删除</button>
				</div>
			</div>
			<div id="div_result_member" style="margin-bottom:15px;">
				<!--#var(Hall hall, PaginatedList<Hall> hallList)-->
				<!--
				#set(
				pager = hallList.pager,
				totalResults = pager.getCountOfTotalResults(),
				totalPages = pager.getCountOfTotalPages() * 1,
				pageSize = pager.pageSize,
				pageNo = pager.pageNo,
				prePageNo = pager.getPrevPageNo(),
				nextPageNo = pager.getNextPageNo()
				)
				-->
				<!--#if(totalResults== null || totalResults==0)-->
				<div class="panel-body">
					<p>没有符合条件的数据</p>
				</div>
				<!--#else-->
				<table class="table table-bordered table-hover table-condensed tb" style="text-align: center; border-top: 0px;">
					<tr>
						<td style="text-align:center;" width="5%"><input type="checkbox" onclick="selectAll()" name="controlAll" style="controlAll" id="controlAll"></td>
						<td style="text-align:center;" width="5%">编号</td>
						<td style="text-align:center;" width="15%">名称</td>
						<td style="text-align:center;" width="10%">负责人</td>
						<td style="text-align:center;" width="15%">手机</td>
						<td style="text-align:center;" width="25%">地址</td>
						<td style="text-align:center;" width="25%">备注</td>
					</tr>
					<!--#foreach(hall in hallList)-->
					<tr>
						<td align="center"><input type="checkbox" name="selected" value="${hall.id}"></td>
						<td>${hall.code}<input type="hidden" name="inputCode${hall.id}" id="inputCode${hall.id}" value="${hall.code}"> </td>
						<td>${hall.name}</td>
						<td>${hall.assignedto}</td>
						<td>${hall.phone}</td>
						<td>${hall.address}</td>
						<td>${hall.remarks}</td>
					</tr>
					<!--#end-->
				</table>
				<div class="paging-page">
					<ul class="pagination">
						<li><a href="yueyogaAdmin/toHallList.jhtml?pageNo=1">首页</a></li>
						<!-- #if(prePageNo<=1) -->
						<li class="disabled"><a href="javascript:void(0)">上一页</a></li>
						<!-- #else -->
						<li><a href="yueyogaAdmin/toHallList.jhtml?pageNo=${prePageNo}">上一页</a></li>
						<!-- #end -->
						<!-- #if(nextPageNo>=totalPages) -->
						<li class="disabled"><a href="javascript:void(0)">下一页</a></li>
						<!-- #else -->
						<li><a href="yueyogaAdmin/toHallList.jhtml?pageNo=${nextPageNo}">下一页</a></li>
						<!-- #end -->
						<li><a href="yueyogaAdmin/toHallList.jhtml?pageNo=${totalPages}">尾页</a></li>
						<li><a>第<input id="txtPageNumber" value="${pageNo}"
								onkeydown="this.value=this.value.replace(/\D/g,'')"
								onkeyup="changePage(this.value)"
								onafterpaste="this.value=this.value.replace(/\D/g,'')" type="text" />页&nbsp;~&nbsp;共${totalPages}页/${totalResults}条
						</a></li>
					</ul>
				</div>
				<!--#end-->
			</div>
		</div>
	</div>
</body>
</html>
<script>
function selectAll(){
	var checklist = document.getElementsByName("selected");
	if(document.getElementById("controlAll").checked){
		for(var i=0;i<checklist.length;i++){
			checklist[i].checked = 1;
		}
	}else{
		for(var j=0;j<checklist.length;j++){
			checklist[j].checked = 0;
		}
	}
}
function deleteHall(){
	var checklist = document.getElementsByName("selected");
	var ids="";
	for(var i=0;i<checklist.length;i++){
		if(checklist[i].checked){
			ids=ids+checklist[i].value+",";
		}
	}
	if(ids==""){
		alert("请选择要删除的行");
	}else{
		confirm("确定要删除吗", function() {
			this.close();
			ids = ids.substring(0, ids.length - 1);
			var d = wait("正在删除，请稍候...");
			var url = "yueyogaAdmin/deleteHall.jhtml?ids="+ids;
			$.post(url,function(response){
				if(response){
					d.content("删除成功");
					setTimeout(function(){
						d.close().remove();
					}, 300);
					window.location.href="yueyogaAdmin/toHallList.jhtml"; 
				}else{
					error("删除失败!");
				}
			}, "json");
		});
	}
}
function updateHall(){
	var checklist = document.getElementsByName("selected");
	var id="";
	var count=0;
	for(var i=0;i<checklist.length;i++){
		if(checklist[i].checked){
			id=id+checklist[i].value;
			count++;
		}
	}
	if(count==1){
		var code=$("#inputCode"+id).val();
		window.location.href="yueyogaAdmin/toEditHall.jhtml?code="+code;
	}else{
		alert("请选择一行进行编辑");
	}
}
function changePage(value) {
	value = value * 1;
	var totalPages = '${totalPages}';
	if (value > totalPages) {
		value = totalPages;
	} else if (value < 1) {
		value = 1;
	}
	$("#txtPageNumber").val(value);
	window.location.href = "yueyogaAdmin/toHallList.jhtml?pageNo=" + value;
}
</script>